extends CharacterBody2D

@onready var destory_timer: Timer = $DestoryTimer
var dic : Vector2

func _ready() -> void:
	destory_timer.timeout.connect(_back_time_destory)

func _process(delta: float) -> void:
	var right = Input.get_axis("ui_left","ui_right")
	var forward = Input.get_axis("ui_up","ui_down")
	dic = Vector2(right,forward).normalized()

func _physics_process(delta: float) -> void:
	velocity = dic * 300
	move_and_slide()

func _destory() -> void:
	destory_timer.call_deferred("start")

func _back_time_destory() -> void:
	owner.players.erase(name)
	call_deferred("queue_free")
